#include<bits/stdc++.h>
#include<cstdio>
#include<map>
#include<queue>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<stack>
using namespace std;
const int maxn=1e5+8;
struct node{
    double d,v,a;
    int cs;
    double l;
    int num,sum;
    int gs;
}a[maxn],cnt,jl[10000005];
int s[maxn];
int main()
{
    freopen("detect1.in","r",stdin);
    freopen("detect.out","w",stdout);
    int n,t,m,L,V;
    cin>>t;
    for(int i=0;i<t;i++)
    {
        cin>>n>>m>>L>>V;
        for(int j=0;j<n;j++)
        {
            cin>>a[j].d>>a[j].v>>a[j].a;
            a[j].cs=0;
            a[j].gs=0;
        }
        for(int j=0;j<m;j++)
        {
            cin>>s[j];
        }
        for(int j=0;j<n;j++)
        {
            if(a[j].v>V||a>0)
            {
                a[j].cs=1;
                a[j].l=a[j].d+((V-a[j].v)*1.0/a[j].a)*a[j].v+0.5*pow(V-a[j].v,2)*1.0/a;
                for(int k=m-1;k>=0;k--)
                {
                    if(s[k]<a[j].l)
                    {
                        cnt.num++;//count over-speed car
                        break;
                    }
                    jl[j].gs=s[k];
                    a[j].gs++;
                }
            }
        }
        cout<<cnt.num;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}

